Next | Prev | Up | Top | Contents | Index

Priority Level Functions

In traditional UNIX systems, one set of functions served all purposes of synchronization and locking: the set-priority-level, or spl, functions. These functions are still available in IRIX, and are summarized in Table 9-20.

Functions to Set Interrupt Levels
Function NameHeader FilesCan Sleep?Purpose
splbase(D3) ddi.hNBlock no interrupts.
spltimeout(D3) ddi.hNBlock only timeout interrupts.
spldisk(D3) ddi.hNBlock disk interrupts.
splstr(D3) ddi.hNBlock STREAMS interrupts.
spltty(D3) ddi.hNBlock disk, VME, serial interrupts.
splhi(D3) ddi.hNBlock all I/O interrupts.
spl0(D3) ddi.hNSame as splbase().
splx(D3) ddi.hNRestore previous interrupt level.

These functions are commonly found in device drivers being ported from uniprocessors. Such drivers rely on the use of splhi() to gain exclusive use of a global resource.

The spl functions are supported by IRIX and they are effective in a uniprocessor driver. However, in a multiprocessor, the functions affect only the interrupt handling of the current CPU. Other CPUs in the system continue to handle interrupts, including interrupts initiated by the driver that called splhi().

A driver that is not multiprocessor-aware (one that does not have D_MP in its pfxdevflag constant; see "Driver Flag Constant") runs only in CPU 0 of a multiprocessor, so in this case the spl functions are still effective. Since they set the interrupt level on CPU 0 where the driver runs, and since the driver's interrupts can only be handled on CPU 0, the use of splhi() gives the driver exclusive use of its resources.

A driver that is multiprocessor-aware uses basic locks, synchronization variables, and other tools to control access to resources, and never uses an spl function. This improves performance in a multiprocessor, does not harm performance in a uniprocessor, and reduces the latency of all interrupts.


Next | Prev | Up | Top | Contents | Index